﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using TestClientsCommon;
using smp.RabbitMq;

namespace Requester2
{
    class Program
    {
        static void Main(string[] args)
        {
            var factory = new RabbitMqFactory();
            using (var requester = factory.CreateRequester("req1"))
            {
                var messageNumber = 0;
                while (true)
                {
                    messageNumber++;
                    var message = new RequestMessage1 { Name = messageNumber.ToString() };
                    Console.WriteLine("Requesting message : " + message.Name);
                    var response = requester.Request<RequestMessage1, Response1>(message);
                    if(response == null)
                    {
                        Console.WriteLine("Response timed out");
                    }
                    else
                    {
                        Console.WriteLine("Recieved response : " + response.Message);
                    }
                    Console.WriteLine();
                    Thread.Sleep(1000);
                }
            }
        }
    }
}
